#pragma once

/************************************************************************/
/* Controls the left PCF8574
	Changelog: - v1.0: Initial release                             */
/************************************************************************/
#include "RP6I2CmasterTWI.h"
#define PCF8574_LEFT_ADDRESS 0x40

uint8_t pcf_left_port=255;//At power-on, all ports are high!
uint8_t pcf_left_isInitialized=true;

void PCF8574_LEFT_allOn(){
	I2CTWI_transmitByte(PCF8574_LEFT_ADDRESS,0b00000000);
}

void PCF8574_LEFT_allOff(){
	I2CTWI_transmitByte(PCF8574_LEFT_ADDRESS,0b11111111);
}

void PCF8574_LEFT_setPorts(uint8_t ports){
	//only update if the ports have changed, that saves a lot of I2C traffic
	if(ports!=pcf_left_port){
		pcf_left_port=ports;
		I2CTWI_transmitByte(PCF8574_LEFT_ADDRESS,ports);
	}	
}